package entity.weapon;

import model.ModelFactory;

import org.lwjgl.util.vector.Vector3f;

import entity.characters.Character;

/**
 * 
 * @author Jevgeni Krutov
 *
 */
public final class RocketLauncher extends Weapon {
	private static final int INITIAL_AMMO = 3;
	private static final long WAIT_INTERVAL = 500;
	
	public RocketLauncher(Character host) {
		super(INITIAL_AMMO, host, WAIT_INTERVAL);
	}

	@Override
	public Shot emitShot(long elapsedTime) {
		if(ammo == 0) {
			return null;
		}
		
		Vector3f forwardVector = host.getNormalisedForwardVector();
		Rocket rocket = new Rocket(
				new Vector3f(Vector3f.add(host.getPosition(), forwardVector, null)),
				new Vector3f(host.getRotation()),
				ModelFactory.getModelInstance("assets/rocket.obj"),
				host.getCurrentW());

		forwardVector.scale(1500f);
		rocket.applyForce(forwardVector);
		
		decrementAmmo();
		
		return rocket;
	}
}
